package company.jd_F;

import java.util.Scanner;

public class JD2 {

    static int max = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        int[][] dict = new int[n][2 * (n - 1) + 1];
        for (int i = 0; i < n; i++) {
            String s = sc.nextLine();
            String trim = s.trim();
            String[] array = trim.split(" ");
            for (int j = n - i - 1, k = 0; k < 2 * i + 1; j++, k++) {
                dict[i][j] = Integer.parseInt(array[k]);
            }
        }
        helper(dict, 0, n - 1, 0, n);
        System.out.println(max);
    }

    private static void helper(int[][] dict, int level, int y, int count, int n) {
        if (level == n) {
            max = Math.max(count, max);
            return;
        }
        if (y < 0 || y >= 2 * n + 1 || dict[level][y] == 0)
            return;
        else {
            count += dict[level][y];
            helper(dict, level + 1, y - 1, count, n);
            helper(dict, level + 1, y, count, n);
            helper(dict, level + 1, y + 1, count, n);
        }
    }
}
